import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n
import i18n from '@/I18n/index'

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control
// 全局组件引入
import Components from '@/components/index'

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 * 判断是否处于生产阶段
 */
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
})

// 全局引入pageTool组件

// 全局组件批量注册
Vue.use(Components)
/* 关闭开发阶段的提示 */
Vue.config.productionTip = false
Vue.directive('errorImg', {
  inserted(el, binding) {
    // console.log('俺是钩子函数')
    el.onerror = function() {
      el.src = binding.value
    }
  }
})
import Print from 'vue-print-nb'
// Global instruction
Vue.use(Print)

// 注册过滤器
import * as filters from '@/filters'// 引入过滤器
// 注册自定义过滤器
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})
//

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
